package com.rs.net.decoders.handlers;

import com.rs.Settings;
import com.rs.cores.WorldThread;
import com.rs.game.Animation;
import com.rs.game.Graphics;
import com.rs.game.World;
import com.rs.game.WorldTile;
import com.rs.game.item.Item;
import com.rs.game.item.MagicOnItem;
import com.rs.game.minigames.CrystalChest;
import com.rs.game.npc.NPC;
import com.rs.game.npc.familiar.Familiar.SpecialAttack;
import com.rs.game.npc.pet.Pet;
import com.rs.game.player.CoordsEvent;
import com.rs.game.player.Equipment;
import com.rs.game.player.Inventory;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;
import com.rs.game.player.QuestManager.Quests;
import com.rs.game.player.actions.BoxAction;
import com.rs.game.player.actions.Firemaking;
import com.rs.game.player.actions.Fletching;
import com.rs.game.player.actions.GemCutting;
import com.rs.game.player.actions.HerbCleaning;
import com.rs.game.player.actions.Herblore;
import com.rs.game.player.actions.LeatherCrafting;
import com.rs.game.player.actions.Summoning;
import com.rs.game.player.actions.BoxAction.HunterEquipment;
import com.rs.game.player.actions.Fletching.Fletch;
import com.rs.game.player.actions.GemCutting.Gem;
import com.rs.game.player.actions.Summoning.Pouches;
import com.rs.game.player.content.AncientEffigies;
import com.rs.game.player.content.ArmourSets;
import com.rs.game.player.content.Dicing;
import com.rs.game.player.content.Foods;
import com.rs.game.player.content.KitManager;
import com.rs.game.player.content.Magic;
import com.rs.game.player.content.Pots;
import com.rs.game.player.content.Runecrafting;
import com.rs.game.player.content.SkillCapeCustomizer;
import com.rs.game.player.content.ArmourSets.Sets;
import com.rs.game.player.content.Burying.Bone;
import com.rs.game.player.content.KitManager.Kits;
import com.rs.game.player.content.KitManager.KitsMade;
import com.rs.game.player.content.Scattering.Ash;
import com.rs.game.player.controlers.Barrows;
import com.rs.game.player.controlers.FightKiln;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.io.InputStream;
import com.rs.utils.Logger;
import com.rs.utils.Utils;

import java.text.DecimalFormat;
import java.util.List;

public class InventoryOptionsHandler {

	public static void handleItemOption2(final Player player, final int slotId, final int itemId, Item item) {
		if (Firemaking.isFiremaking(player, itemId)) {
			return;
		}
		switch (itemId) {
		case 7927:
		case 6583:
		case 22560:
			int npcId = -1;
			player.stopAll();
			player.lock();
			player.getInterfaceManager().sendInventoryInterface(375);
			player.getTemporaryAttributes().put("RingNPC", Boolean.TRUE);
			switch (itemId) {
			case 7927:
				int[] randomEggs = { 3689, 3690, 3692, 3693, 3664 };
				npcId = randomEggs[Utils.random(randomEggs.length - 1)];
				break;
			case 6583:
			case 22560:
				npcId = 2626;
				break;
			}
			player.getAppearence().transformIntoNPC(npcId);
			break;
		case 4155:
			if (player.getTask() != null) {
				player.getPackets().sendGameMessage("Your current assignment is: " + player.getTask().getName().toLowerCase() + "s; only " + player.getTask().getTaskAmount() + " more to go.");
			} else {
				player.getPackets().sendGameMessage("You need something new to hunt; return to a Slayer master.");
			}
			break;	
		case 5509:
		case 5510:
		case 5511:
		case 5512:
		case 5513:
		case 5514:
			int pouch = -1;
			if (itemId == 5509) {
				pouch = 0;
			}
			if (itemId == 5510) {
				pouch = 1;
			}
			if (itemId == 5512) {
				pouch = 2;
			}
			if (itemId == 5514) {
				pouch = 3;
			}
			Runecrafting.emptyPouch(player, pouch);
			player.stopAll(false);
			break;
		case 15086:
		case 15087:
		case 15088:
		case 15089:
		case 15090:
		case 15091:
		case 15092:
		case 15093:
		case 15094:
		case 15095:
		case 15096:
		case 15097:
		case 15098:
		case 15099:
		case 15100:
			Dicing.handleRoll(player, itemId, true);
			break;
		default:
			if (player.isEquipDisabled()) {
				return;
			}
			long passedTime = Utils.currentTimeMillis() - WorldThread.LAST_CYCLE_CTM;
			WorldTasksManager.schedule(new WorldTask() {
				
				@Override
				public void run() {
					List<Integer> slots = player.getSwitchItemCache();
					int[] slot = new int[slots.size()];
					for (int i = 0; i < slot.length; i++) {
						slot[i] = slots.get(i);
					}
					player.getSwitchItemCache().clear();
					ButtonHandler.sendWear(player, slot);
					player.stopAll(false, true, false);
				}
			}, passedTime >= 600 ? 0 : passedTime > 330 ? 1 : 0);
			if (player.getSwitchItemCache().contains(slotId)) {
				return;
			}
			player.getSwitchItemCache().add(slotId);
		}
	}
	public static void DFS(Player player, final int slotId, final int itemId) {
			if (itemId == 11283) {
				player.out("Your shield has " +player.DFS+ " charges.");
			} else {
			}
		}
	

	public static void dig(final Player player) {
		player.resetWalkSteps();
		player.setNextAnimation(new Animation(830));
		player.lock();
		WorldTasksManager.schedule(new WorldTask() {

			@Override
			public void run() {
				player.unlock();
				if (Barrows.digIntoGrave(player))
					return;
				if (player.getX() == 3005 && player.getY() == 3376 || player.getX() == 2999 && player.getY() == 3375 || player.getX() == 2996 && player.getY() == 3377 || player.getX() == 2989 && player.getY() == 3378 || player.getX() == 2987 && player.getY() == 3387 || player.getX() == 2984 && player.getY() == 3387) {
					// mole
					player.setNextWorldTile(new WorldTile(1752, 5137, 0));
					player.getPackets().sendGameMessage("You seem to have dropped down into a network of mole tunnels.");
					return;
				}
				player.getPackets().sendGameMessage("You find nothing.");
			}

		});
	}

	public static void handleItemOption1(Player player, final int slotId, final int itemId, Item item) {
		long time = Utils.currentTimeMillis();
		Bone bone = Bone.forId(itemId);
		Ash ash = Ash.forId(itemId);
		if (player.getLockDelay() >= time || player.getEmotesManager().getNextEmoteEnd() >= time) {
			return;
		}
		player.stopAll(false);
		if (Foods.eat(player, item, slotId)) {
			return;
		}
		if (Pots.pot(player, item, slotId)) {
			return;
		}
		if (HerbCleaning.clean(player, item, slotId)) {
			return;
		}
		if (bone != null) {
			Bone.bury(player, slotId);
			return;
		}
		if (itemId == 14664) {
			player.lock(3);
			player.getInterfaceManager().sendInterface(1123);
			player.sm("Random event gift box opens... please, select a reward.");
		}
		if (ash != null) {
			Ash.scatter(player, slotId);
		}
		if (Magic.useTabTeleport(player, itemId)) {
			return;
		}
		if (itemId == HunterEquipment.BOX.getId()) {
			player.getActionManager().setAction(new BoxAction(HunterEquipment.BOX));
		}
		if (itemId == HunterEquipment.BRID_SNARE.getId()) {
			player.getActionManager().setAction(new BoxAction(HunterEquipment.BRID_SNARE));
		}
		if (item.getDefinitions().getName().startsWith("Burnt")) {
			player.getDialogueManager().startDialogue("SimplePlayerMessage", "Ugh, this is inedible.");
		}
		switch (itemId) {
		case 6:
			if (!player.getDwarfCannon().hasCannon() && player.getQuestManager().completedQuest(Quests.DWARF_CANNON)) {
				player.getDwarfCannon().cannonSetup();
			}
			break;
		case 20498:
			if (!player.getDwarfCannon().hasCannon() && player.getQuestManager().completedQuest(Quests.DWARF_CANNON)) {
				player.getDwarfCannon().royalCannonSetup();
			}
			break;
		case 20494:
			if (!player.getDwarfCannon().hasCannon() && player.getQuestManager().completedQuest(Quests.DWARF_CANNON)) {
				player.getDwarfCannon().goldCannonSetup();
			}
			break;
			
		case 771:
			player.getInventory().deleteItem(771, 1);
			player.getInventory().addItem(772, 1);
			player.getInventory().refresh();
			return;
		case 5073:
			int rewards[] = { 5312, 5283, 5284, 5285, 5286, 5288, 5289, 5290, 5313, 5314, 5287, 5315, 5316, 5317 };
			int reward = rewards[Utils.random(rewards.length - 1)];
			player.getInventory().addItem(reward, 1);
			player.getInventory().deleteItem(5073, 1);
			player.getInventory().addItem(5075, 1);
			break;
		case 15086:
		case 15087:
		case 15088:
		case 15089:
		case 15090:
		case 15091:
		case 15092:
		case 15093:
		case 15094:
		case 15095:
		case 15096:
		case 15097:
		case 15098:
		case 15099:
		case 15100:
			Dicing.handleRoll(player, itemId, false);
			break;
		case 5509:
		case 5510:
		case 5511:
		case 5512:
		case 5513:
		case 5514:
			int pouch = -1;
			if (itemId == 5509) {
				pouch = 0;
			}
			if (itemId == 5510) {
				pouch = 1;
			}
			if (itemId == 5512) {
				pouch = 2;
			}
			if (itemId == 5514) {
				pouch = 3;
			}
			Runecrafting.emptyPouch(player, pouch);
			break;
		case 22370:
			Summoning.openDreadnipInterface(player);
			break;
		case 952:
			dig(player);
			break;
		case AncientEffigies.SATED_ANCIENT_EFFIGY:
		case AncientEffigies.GORGED_ANCIENT_EFFIGY:
		case AncientEffigies.NOURISHED_ANCIENT_EFFIGY:
		case AncientEffigies.STARVED_ANCIENT_EFFIGY:
			player.getDialogueManager().startDialogue("AncientEffigiesD", itemId);
			break;
		case 4155:
			player.getDialogueManager().startDialogue("EnchantedGemDialouge");
			break;
		case 23653:
		case 23654:
		case 23655:
		case 23656:
		case 23657:
		case 23658:
			FightKiln.useCrystal(player, itemId);
			break;
		case 405:
			int[] rewards2 = { 2000000, 3000000, 4000000, 5000000, 7500000 };
			int won = rewards2[Utils.random(rewards2.length - 1)];
			player.getInventory().deleteItem(405, 1);
			player.getInventory().addItem(995, won);
			player.getPackets().sendGameMessage("The casket slowly opens... You receive " + won + " coins!");
			break;
		case 24155:
			player.getPackets().sendGameMessage("You opened your spin ticket and recieved two spins.");
			player.setSpins(player.getSpins() + 2);
			player.getPackets().sendIComponentText(1139, 10, " " + player.getSpins() + " ");
			player.getInventory().deleteItem(24155, 1);
			break;
		case 24714:
			player.getInterfaceManager().sendInterface(1263);
			break;
		case 24154:
			player.getPackets().sendGameMessage("You opened your spin ticket and recieved a spin.");
			player.setSpins(player.getSpins() + 1);
			player.getPackets().sendIComponentText(1139, 10, " " + player.getSpins() + " ");
			player.getInventory().deleteItem(24154, 1);
			break;
		case 23717:
			player.getSkills().addXp(Skills.ATTACK, 2500);
			player.getInventory().deleteItem(23717, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Attack Experience.");
			break;
		case 23721:
			player.getSkills().addXp(Skills.STRENGTH, 2500);
			player.getInventory().deleteItem(23721, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Strength Experience.");
			break;
		case 23725:
			player.getSkills().addXp(Skills.DEFENCE, 2500);
			player.getInventory().deleteItem(23725, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Defence Experience.");
			break;
		case 23729:
			player.getSkills().addXp(Skills.RANGE, 2500);
			player.getInventory().deleteItem(23729, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Range Experience.");
			break;
		case 23733:
			player.getSkills().addXp(Skills.MAGIC, 2500);
			player.getInventory().deleteItem(23733, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Magic Experience.");
			break;
		case 23737:
			player.getSkills().addXp(Skills.PRAYER, 2500);
			player.getInventory().deleteItem(23737, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Prayer Experience.");
			break;
		case 23741:
			player.getSkills().addXp(Skills.RUNECRAFTING, 2500);
			player.getInventory().deleteItem(23741, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Runecrafting Experience.");
			break;
		case 23745:
			player.getSkills().addXp(Skills.CONSTRUCTION, 2500);
			player.getInventory().deleteItem(23745, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Construction Experience.");
			break;
		case 23749:
			player.getSkills().addXp(Skills.DUNGEONEERING, 2500);
			player.getInventory().deleteItem(23749, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Dungeoneering Experience.");
			break;
		case 23753:
			player.getSkills().addXp(Skills.HITPOINTS, 2500);
			player.getInventory().deleteItem(23753, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Constitution Experience.");
			break;
		case 23757:
			player.getSkills().addXp(Skills.AGILITY, 2500);
			player.getInventory().deleteItem(23757, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Agility Experience.");
			break;
		case 23761:
			player.getSkills().addXp(Skills.HERBLORE, 2500);
			player.getInventory().deleteItem(23761, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Herblore Experience.");
			break;
		case 23765:
			player.getSkills().addXp(Skills.THIEVING, 2500);
			player.getInventory().deleteItem(23765, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Thieving Experience.");
			break;
		case 23769:
			player.getSkills().addXp(Skills.CRAFTING, 2500);
			player.getInventory().deleteItem(23769, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Crafting Experience.");
			break;
		case 23774:
			player.getSkills().addXp(Skills.FLETCHING, 2500);
			player.getInventory().deleteItem(23774, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Fletching Experience.");
			break;
		case 23778:
			player.getSkills().addXp(Skills.SLAYER, 2500);
			player.getInventory().deleteItem(23778, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Slayer Experience.");
			break;
		case 23782:
			player.getSkills().addXp(Skills.HUNTER, 2500);
			player.getInventory().deleteItem(23782, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Hunter Experience.");
			break;
		case 23786:
			player.getSkills().addXp(Skills.MINING, 2500);
			player.getInventory().deleteItem(23786, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Mining Experience.");
			break;
		case 23790:
			player.getSkills().addXp(Skills.SMITHING, 2500);
			player.getInventory().deleteItem(23790, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Smithing Experience.");
			break;
		case 23794:
			player.getSkills().addXp(Skills.FISHING, 2500);
			player.getInventory().deleteItem(23794, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Fishing Experience.");
			break;
		case 23798:
			player.getSkills().addXp(Skills.COOKING, 2500);
			player.getInventory().deleteItem(23798, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Cooking Experience.");
			break;
		case 23802:
			player.getSkills().addXp(Skills.FIREMAKING, 2500);
			player.getInventory().deleteItem(23802, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Firemaking Experience.");
			break;
		case 23806:
			player.getSkills().addXp(Skills.WOODCUTTING, 2500);
			player.getInventory().deleteItem(23806, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Woodcutting Experience.");
			break;
		case 23810:
			player.getSkills().addXp(Skills.FARMING, 2500);
			player.getInventory().deleteItem(23810, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Farming Experience.");
			break;
		case 23814:
			player.getSkills().addXp(Skills.SUMMONING, 2500);
			player.getInventory().deleteItem(23814, 1);
			player.getPackets().sendGameMessage("You have earned yourself some Summoning Experience.");
			break;
		case 23718:
			player.getSkills().addXp(Skills.ATTACK, 5000);
			player.getInventory().deleteItem(23718, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Attack.");
			break;
		case 23722:
			player.getSkills().addXp(Skills.STRENGTH, 5000);
			player.getInventory().deleteItem(23722, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Strength.");
			break;
		case 23726:
			player.getSkills().addXp(Skills.DEFENCE, 5000);
			player.getInventory().deleteItem(23726, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Defence.");
			break;
		case 23730:
			player.getSkills().addXp(Skills.RANGE, 5000);
			player.getInventory().deleteItem(23730, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Range.");
			break;
		case 23734:
			player.getSkills().addXp(Skills.MAGIC, 5000);
			player.getInventory().deleteItem(23734, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Magic.");
			break;
		case 23738:
			player.getSkills().addXp(Skills.PRAYER, 5000);
			player.getInventory().deleteItem(23738, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Prayer.");
			break;
		case 23742:
			player.getSkills().addXp(Skills.RUNECRAFTING, 5000);
			player.getInventory().deleteItem(23742, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Runecrafting.");
			break;
		case 23746:
			player.getSkills().addXp(Skills.CONSTRUCTION, 5000);
			player.getInventory().deleteItem(23746, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Construction.");
			break;
		case 23750:
			player.getSkills().addXp(Skills.DUNGEONEERING, 5000);
			player.getInventory().deleteItem(23750, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Dungeoneering.");
			break;
		case 23754:
			player.getSkills().addXp(Skills.HITPOINTS, 5000);
			player.getInventory().deleteItem(23754, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Constitution.");
			break;
		case 23758:
			player.getSkills().addXp(Skills.AGILITY, 5000);
			player.getInventory().deleteItem(23758, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Agility.");
			break;
		case 23762:
			player.getSkills().addXp(Skills.HERBLORE, 5000);
			player.getInventory().deleteItem(23762, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Herblore.");
			break;
		case 23766:
			player.getSkills().addXp(Skills.THIEVING, 5000);
			player.getInventory().deleteItem(23766, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Thieving.");
			break;
		case 23770:
			player.getSkills().addXp(Skills.CRAFTING, 5000);
			player.getInventory().deleteItem(23770, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Crafting.");
			break;
		case 23775:
			player.getSkills().addXp(Skills.FLETCHING, 5000);
			player.getInventory().deleteItem(23775, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Fletching.");
			break;
		case 23779:
			player.getSkills().addXp(Skills.SLAYER, 5000);
			player.getInventory().deleteItem(23779, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Slayer.");
			break;
		case 23783:
			player.getSkills().addXp(Skills.HUNTER, 5000);
			player.getInventory().deleteItem(23783, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Hunter.");
			break;
		case 23787:
			player.getSkills().addXp(Skills.MINING, 5000);
			player.getInventory().deleteItem(23787, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Mining.");
			break;
		case 23791:
			player.getSkills().addXp(Skills.SMITHING, 5000);
			player.getInventory().deleteItem(23791, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Smithing.");
			break;
		case 23795:
			player.getSkills().addXp(Skills.FISHING, 5000);
			player.getInventory().deleteItem(23795, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Fishing.");
			break;
		case 23799:
			player.getSkills().addXp(Skills.COOKING, 5000);
			player.getInventory().deleteItem(23799, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Cooking.");
			break;
		case 23803:
			player.getSkills().addXp(Skills.FIREMAKING, 5000);
			player.getInventory().deleteItem(23803, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Firemaking.");
			break;
		case 23807:
			player.getSkills().addXp(Skills.WOODCUTTING, 5000);
			player.getInventory().deleteItem(23807, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Woodcutting.");
			break;
		case 23811:
			player.getSkills().addXp(Skills.FARMING, 5000);
			player.getInventory().deleteItem(23811, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Farming.");
			break;
		case 23815:
			player.getSkills().addXp(Skills.SUMMONING, 5000);
			player.getInventory().deleteItem(23815, 1);
			player.getPackets().sendGameMessage("You feel more experienced in Summoning.");
			break;
		case 23719:
			player.getSkills().addXp(Skills.ATTACK, 7500);
			player.getInventory().deleteItem(23719, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Attack.");
			break;
		case 23723:
			player.getSkills().addXp(Skills.STRENGTH, 7500);
			player.getInventory().deleteItem(23723, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Strength.");
			break;
		case 23727:
			player.getSkills().addXp(Skills.DEFENCE, 7500);
			player.getInventory().deleteItem(23727, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Defence.");
			break;
		case 23731:
			player.getSkills().addXp(Skills.RANGE, 7500);
			player.getInventory().deleteItem(23731, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Range.");
			break;
		case 23735:
			player.getSkills().addXp(Skills.MAGIC, 7500);
			player.getInventory().deleteItem(23735, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Magic.");
			break;
		case 23739:
			player.getSkills().addXp(Skills.PRAYER, 7500);
			player.getInventory().deleteItem(23739, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Prayer.");
			break;
		case 23743:
			player.getSkills().addXp(Skills.RUNECRAFTING, 7500);
			player.getInventory().deleteItem(23743, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Runecrafting.");
			break;
		case 23747:
			player.getSkills().addXp(Skills.CONSTRUCTION, 7500);
			player.getInventory().deleteItem(23747, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Construction.");
			break;
		case 23751:
			player.getSkills().addXp(Skills.DUNGEONEERING, 7500);
			player.getInventory().deleteItem(23751, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Dungeoneering.");
			break;
		case 23755:
			player.getSkills().addXp(Skills.HITPOINTS, 7500);
			player.getInventory().deleteItem(23755, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Constitution.");
			break;
		case 23759:
			player.getSkills().addXp(Skills.AGILITY, 7500);
			player.getInventory().deleteItem(23759, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Agility.");
			break;
		case 23763:
			player.getSkills().addXp(Skills.HERBLORE, 7500);
			player.getInventory().deleteItem(23763, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Herblore.");
			break;
		case 23767:
			player.getSkills().addXp(Skills.THIEVING, 7500);
			player.getInventory().deleteItem(23767, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Thieving.");
			break;
		case 23771:
			player.getSkills().addXp(Skills.CRAFTING, 7500);
			player.getInventory().deleteItem(23771, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Crafting.");
			break;
		case 23776:
			player.getSkills().addXp(Skills.FLETCHING, 7500);
			player.getInventory().deleteItem(23776, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Fletching.");
			break;
		case 23780:
			player.getSkills().addXp(Skills.SLAYER, 7500);
			player.getInventory().deleteItem(23780, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Slayer.");
			break;
		case 23784:
			player.getSkills().addXp(Skills.HUNTER, 7500);
			player.getInventory().deleteItem(23784, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Hunter.");
			break;
		case 23788:
			player.getSkills().addXp(Skills.MINING, 7500);
			player.getInventory().deleteItem(23788, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Mining.");
			break;
		case 23792:
			player.getSkills().addXp(Skills.SMITHING, 7500);
			player.getInventory().deleteItem(23792, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Smithing.");
			break;
		case 23796:
			player.getSkills().addXp(Skills.FISHING, 7500);
			player.getInventory().deleteItem(23796, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Fishing.");
			break;
		case 23800:
			player.getSkills().addXp(Skills.COOKING, 7500);
			player.getInventory().deleteItem(23800, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Cooking.");
			break;
		case 23804:
			player.getSkills().addXp(Skills.FIREMAKING, 7500);
			player.getInventory().deleteItem(23804, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Firemaking.");
			break;
		case 23808:
			player.getSkills().addXp(Skills.WOODCUTTING, 7500);
			player.getInventory().deleteItem(23808, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Woodcutting.");
			break;
		case 23812:
			player.getSkills().addXp(Skills.FARMING, 7500);
			player.getInventory().deleteItem(23812, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Farming.");
			break;
		case 23816:
			player.getSkills().addXp(Skills.SUMMONING, 7500);
			player.getInventory().deleteItem(23816, 1);
			player.getPackets().sendGameMessage("You feel a magical force give you great knowledge in Summoning.");
			break;
		case 23720:
			player.getSkills().addXp(Skills.ATTACK, 10000);
			player.getInventory().deleteItem(23720, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Attack.");
			break;
		case 23724:
			player.getSkills().addXp(Skills.STRENGTH, 10000);
			player.getInventory().deleteItem(23724, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Strength.");
			break;
		case 23728:
			player.getSkills().addXp(Skills.DEFENCE, 10000);
			player.getInventory().deleteItem(23728, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Defence.");
			break;
		case 23732:
			player.getSkills().addXp(Skills.RANGE, 10000);
			player.getInventory().deleteItem(23732, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Range.");
			break;
		case 23736:
			player.getSkills().addXp(Skills.MAGIC, 10000);
			player.getInventory().deleteItem(23736, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Magic.");
			break;
		case 23740:
			player.getSkills().addXp(Skills.PRAYER, 10000);
			player.getInventory().deleteItem(23740, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Prayer.");
			break;
		case 23744:
			player.getSkills().addXp(Skills.RUNECRAFTING, 10000);
			player.getInventory().deleteItem(23744, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Runecrafting.");
			break;
		case 23748:
			player.getSkills().addXp(Skills.CONSTRUCTION, 10000);
			player.getInventory().deleteItem(23748, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Construction.");
			break;
		case 23752:
			player.getSkills().addXp(Skills.DUNGEONEERING, 10000);
			player.getInventory().deleteItem(23752, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Dungeoneering.");
			break;
		case 23756:
			player.getSkills().addXp(Skills.HITPOINTS, 10000);
			player.getInventory().deleteItem(23756, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Constitution.");
			break;
		case 23760:
			player.getSkills().addXp(Skills.AGILITY, 10000);
			player.getInventory().deleteItem(23760, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Agility.");
			break;
		case 23764:
			player.getSkills().addXp(Skills.HERBLORE, 10000);
			player.getInventory().deleteItem(23764, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Herblore.");
			break;
		case 23768:
			player.getSkills().addXp(Skills.THIEVING, 10000);
			player.getInventory().deleteItem(23768, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Thieving.");
			break;
		case 23772:
			player.getSkills().addXp(Skills.CRAFTING, 10000);
			player.getInventory().deleteItem(23772, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Crafting.");
			break;
		case 23777:
			player.getSkills().addXp(Skills.FLETCHING, 10000);
			player.getInventory().deleteItem(23777, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Fletching.");
			break;
		case 23781:
			player.getSkills().addXp(Skills.SLAYER, 10000);
			player.getInventory().deleteItem(23781, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Slayer.");
			break;
		case 23785:
			player.getSkills().addXp(Skills.HUNTER, 10000);
			player.getInventory().deleteItem(23785, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Hunter.");
			break;
		case 23789:
			player.getSkills().addXp(Skills.MINING, 10000);
			player.getInventory().deleteItem(23789, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Mining.");
			break;
		case 23793:
			player.getSkills().addXp(Skills.SMITHING, 10000);
			player.getInventory().deleteItem(23793, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Smithing.");
			break;
		case 23797:
			player.getSkills().addXp(Skills.FISHING, 10000);
			player.getInventory().deleteItem(23797, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Fishing.");
			break;
		case 23801:
			player.getSkills().addXp(Skills.COOKING, 10000);
			player.getInventory().deleteItem(23801, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Cooking.");
			break;
		case 23805:
			player.getSkills().addXp(Skills.FIREMAKING, 10000);
			player.getInventory().deleteItem(23805, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Firemaking.");
			break;
		case 23809:
			player.getSkills().addXp(Skills.WOODCUTTING, 10000);
			player.getInventory().deleteItem(23809, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Woodcutting.");
			break;
		case 23813:
			player.getSkills().addXp(Skills.FARMING, 10000);
			player.getInventory().deleteItem(23813, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Farming.");
			break;
		case 23817:
			player.getSkills().addXp(Skills.SUMMONING, 10000);
			player.getInventory().deleteItem(23817, 1);
			player.getPackets().sendGameMessage("You have been granted great experience in Summoning.");
			break;
		case 23714:
			player.getDialogueManager().startDialogue("MediumXPLamp");
			break;
		case 24300:
			player.getSkills().addXp(Skills.ATTACK, 10000);
			player.getSkills().addXp(Skills.STRENGTH, 10000);
			player.getSkills().addXp(Skills.DEFENCE, 10000);
			player.getSkills().addXp(Skills.RANGE, 10000);
			player.getSkills().addXp(Skills.MAGIC, 10000);
			player.getSkills().addXp(Skills.PRAYER, 66666.66666666667);
			player.getSkills().addXp(Skills.RUNECRAFTING, 13333.33333333333);
			player.getSkills().addXp(Skills.CONSTRUCTION, 13333.33333333333);
			player.getSkills().addXp(Skills.DUNGEONEERING, 13333.33333333333);
			player.getSkills().addXp(Skills.HITPOINTS, 13333.33333333333);
			player.getSkills().addXp(Skills.AGILITY, 6666.67);
			player.getSkills().addXp(Skills.HERBLORE, 25000);
			player.getSkills().addXp(Skills.THIEVING, 13333.33333333333);
			player.getSkills().addXp(Skills.CRAFTING, 13333.33333333333);
			player.getSkills().addXp(Skills.FLETCHING, 6666.67);
			player.getSkills().addXp(Skills.SLAYER, 13333.33333333333);
			player.getSkills().addXp(Skills.HUNTER, 13333.33333333333);
			player.getSkills().addXp(Skills.MINING, 13333.33333333333);
			player.getSkills().addXp(Skills.SMITHING, 6666.67);
			player.getSkills().addXp(Skills.FISHING, 13333.33333333333);
			player.getSkills().addXp(Skills.COOKING, 13333.33333333333);
			player.getSkills().addXp(Skills.FIREMAKING, 13333.33333333333);
			player.getSkills().addXp(Skills.WOODCUTTING, 13333.33333333333);
			player.getSkills().addXp(Skills.FARMING, 13333.33333333333);
			player.getSkills().addXp(Skills.SUMMONING, 13333.33333333333);
			player.getPackets().sendGameMessage("The gods have heard your plea, and grant you 2,000,000 Experience!");
			player.getInventory().deleteItem(24300, 1);
			break;
		case 1856:
			player.getInterfaceManager().sendInterface(275);
			player.getPackets().sendIComponentText(275, 1, "Welcome to " + Settings.SERVER_NAME + ".");
			player.getPackets().sendIComponentText(275, 11, "");
			player.getPackets().sendIComponentText(275, 10, "Welcome to " + Settings.SERVER_NAME + " RSPS.");
			player.getPackets().sendIComponentText(275, 12, "Geryon RSPS is a wonderful economy server.");
			player.getPackets().sendIComponentText(275, 13, "Everywhere You Turn, There Are Many");
			player.getPackets().sendIComponentText(275, 14, "opportunities Such As Skilling, Bossing, ");
			player.getPackets().sendIComponentText(275, 15, "Player Killing, and Minigames!");
			player.getPackets().sendIComponentText(275, 16, "We are Home of Amazing Content!");
			player.getPackets().sendIComponentText(275, 17, "");
			player.getPackets().sendIComponentText(275, 18, "If You Need Any Help, Do ::ticket. (Don't abuse it)");
			player.getPackets().sendIComponentText(275, 19, "");
			player.getPackets().sendIComponentText(275, 20, "Also, You Can Compare Stats With Friends.");
			player.getPackets().sendIComponentText(275, 21, "");
			player.getPackets().sendIComponentText(275, 22, "Oh and Yeah, Don't Forget To ::Vote and Follow Rules.");
			player.getPackets().sendIComponentText(275, 23, "");
			player.getPackets().sendIComponentText(275, 24, "Visit The Website: " + Settings.WEBSITE_LINK);
			player.getPackets().sendIComponentText(275, 25, "");
			player.getPackets().sendIComponentText(275, 26, "Enjoy your time on " + Settings.SERVER_NAME + ".");
			player.getPackets().sendIComponentText(275, 27, "<img=1> Geryon Staff Team");
			player.getPackets().sendIComponentText(275, 28, "");
			player.getPackets().sendIComponentText(275, 29, "");
			player.getPackets().sendIComponentText(275, 30, "");
			player.getPackets().sendIComponentText(275, 31, "");
			player.getPackets().sendIComponentText(275, 32, "");
			player.getPackets().sendIComponentText(275, 33, "");
			player.getPackets().sendIComponentText(275, 34, "");
			player.getPackets().sendIComponentText(275, 35, "");
			player.getPackets().sendIComponentText(275, 36, "");
			player.getPackets().sendIComponentText(275, 37, "");
			player.getPackets().sendIComponentText(275, 38, "");
			player.getPackets().sendIComponentText(275, 39, "");
			player.getPackets().sendIComponentText(275, 40, "");
			for (int i = 31; i < 300; i++) {
				player.getPackets().sendIComponentText(275, i, "");
			}
			break;
		case 18782:
			for (int i = 0; i < 50; i++)
				player.getPackets().sendUnlockIComponentOptionSlots(1263, i, 0, 1, 0);
			player.getInterfaceManager().sendInterface(1263);
			break;

		case 15262:
			if (player.getInventory().getFreeSlots() > 1) {
				player.getInventory().deleteItem(15262, 1);
				player.getInventory().addItem(12183, 5000);
			}
			break;
		}

		if (player.getRights() == 2) {
			player.sendMessage("Item Select:" + itemId + ", Slot Id:" + slotId);
		}
	}

	/*
	 * returns the other
	 */
	public static Item contains(int id1, Item item1, Item item2) {
		if (item1.getId() == id1) {
			return item2;
		}
		if (item2.getId() == id1) {
			return item1;
		}
		return null;
	}

	public static boolean contains(int id1, int id2, Item... items) {
		boolean containsId1 = false;
		boolean containsId2 = false;
		for (Item item : items) {
			if (item.getId() == id1) {
				containsId1 = true;
			} else if (item.getId() == id2) {
				containsId2 = true;
			}
		}
		return containsId1 && containsId2;
	}

	public static void handleItemOnItem(final Player player, InputStream stream) {
		if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead())
			return;
		if (player.getLockDelay() > Utils.currentTimeMillis())
			return;
	    int itemUsedWithId = stream.readShort();
	    int toSlot = stream.readShortLE128();
	    int hash1 = stream.readInt();
	    int hash2 = stream.readInt();
	    int interfaceId = hash1 >> 16;
	    int interfaceId2 = hash2 >> 16;
	    int comp1 = hash1 & 0xFFFF;
	    int fromSlot = stream.readShort();
	    int itemUsedId = stream.readShortLE128();
		switch (interfaceId) {
		case 747:
		case 662:
			if (player.getFamiliar() == null || player.getFamiliar().getSpecialAttack() != SpecialAttack.ITEM)
				return;
			player.getFamiliar().submitSpecial(toSlot);
			return;
		}
		if (interfaceId == 192 && interfaceId2 == 679) {
		    MagicOnItem.handleMagic(player, comp1, player.getInventory().getItem(toSlot));
		    return;
		}
		if ((interfaceId2 == 747 || interfaceId2 == 662) && interfaceId == Inventory.INVENTORY_INTERFACE) {
			if (player.getFamiliar() != null) {
				player.getFamiliar().setSpecial(true);
				if (player.getFamiliar().getSpecialAttack() == SpecialAttack.ITEM) {
					player.getFamiliar().submitSpecial(toSlot);
				}
			}
			return;
		}

		if (interfaceId == Inventory.INVENTORY_INTERFACE && interfaceId == interfaceId2 && !player.getInterfaceManager().containsInventoryInter()) {
			if (toSlot >= 28 || fromSlot >= 28) {
				return;
			}
			Item usedWith = player.getInventory().getItem(toSlot);
			Item itemUsed = player.getInventory().getItem(fromSlot);
			if (itemUsed == null || usedWith == null || itemUsed.getId() != itemUsedId || usedWith.getId() != itemUsedWithId) {
				return;
			}
			player.stopAll();
			if (!player.getControlerManager().canUseItemOnItem(itemUsed, usedWith)) {
				return;
			}
			Fletch fletch = Fletching.isFletching(usedWith, itemUsed);
			if (fletch != null) {
				player.getDialogueManager().startDialogue("FletchingD", fletch);
				return;
			}
			if (itemUsed.getId() == CrystalChest.toothHalf() && usedWith.getId() == CrystalChest.loopHalf() || itemUsed.getId() == CrystalChest.loopHalf() && usedWith.getId() == CrystalChest.toothHalf()) {
				CrystalChest.makeKey(player);
				return;
			}
			if (Kits.kits.containsKey(usedWith.getId())) {
				KitManager.createItem(player, itemUsed.getId(), usedWith.getId());
				return;
			}
			if ((itemUsed.getId() == 1759 && usedWith.getId() == 1673) || (itemUsed.getId() == 1673 && usedWith.getId() == 1759)) {
				if (player.getSkills().getLevel(Skills.CRAFTING) >= 8) {
					player.getInventory().deleteItem(1759, 1);
					player.getInventory().deleteItem(1673, 1);
					player.getInventory().addItem(1692, 1);
					player.getSkills().addXp(Skills.CRAFTING, 4);
					player.getPackets().sendGameMessage("You string the amulet to create a Gold amulet.");
					return;
				} else {
					player.getDialogueManager().startDialogue("SimpleMessage", "You need a crafting level of 8 to create that.");
					return;
				}
			}
			if ((itemUsed.getId() == 1759 && usedWith.getId() == 1675) || (itemUsed.getId() == 1675 && usedWith.getId() == 1759)) {
				if (player.getSkills().getLevel(Skills.CRAFTING) >= 24) {
					player.getInventory().deleteItem(1759, 1);
					player.getInventory().deleteItem(1675, 1);
					player.getInventory().addItem(1727, 1);
					player.getSkills().addXp(Skills.CRAFTING, 4);
					player.getPackets().sendGameMessage("You string the amulet to create an Amulet of Magic.");
					return;
				} else {
					player.getDialogueManager().startDialogue("SimpleMessage", "You need a crafting level of 24 to create that.");
					return;
				}
			}
			if ((itemUsed.getId() == 1759 && usedWith.getId() == 1677) || (itemUsed.getId() == 1677 && usedWith.getId() == 1759)) {
				if (player.getSkills().getLevel(Skills.CRAFTING) >= 31) {
					player.getInventory().deleteItem(1759, 1);
					player.getInventory().deleteItem(1677, 1);
					player.getInventory().addItem(1729, 1);
					player.getSkills().addXp(Skills.CRAFTING, 4);
					player.getPackets().sendGameMessage("You string the amulet to create an Amulet of Defence.");
					return;
				} else {
					player.getDialogueManager().startDialogue("SimpleMessage", "You need a crafting level of 31 to create that.");
					return;
				}
			}
			if ((itemUsed.getId() == 1759 && usedWith.getId() == 1679) || (itemUsed.getId() == 1679 && usedWith.getId() == 1759)) {
				if (player.getSkills().getLevel(Skills.CRAFTING) >= 50) {
					player.getInventory().deleteItem(1759, 1);
					player.getInventory().deleteItem(1679, 1);
					player.getInventory().addItem(1725, 1);
					player.getSkills().addXp(Skills.CRAFTING, 4);
					player.getPackets().sendGameMessage("You string the amulet to create an Amulet of Strength.");
					return;
				} else {
					player.getDialogueManager().startDialogue("SimpleMessage", "You need a crafting level of 50 to create that.");
					return;
				}
			}
			if ((itemUsed.getId() == 1759 && usedWith.getId() == 1681) || (itemUsed.getId() == 1681 && usedWith.getId() == 1759)) {
				if (player.getSkills().getLevel(Skills.CRAFTING) >= 70) {
					player.getInventory().deleteItem(1759, 1);
					player.getInventory().deleteItem(1681, 1);
					player.getInventory().addItem(1731, 1);
					player.getSkills().addXp(Skills.CRAFTING, 4);
					player.getPackets().sendGameMessage("You string the amulet to create an Amulet of Power.");
					return;
				} else {
					player.getDialogueManager().startDialogue("SimpleMessage", "You need a crafting level of 70 to create that.");
					return;
				}
			}
			if ((itemUsed.getId() == 1759 && usedWith.getId() == 1683) || (itemUsed.getId() == 1683 && usedWith.getId() == 1759)) {
				if (player.getSkills().getLevel(Skills.CRAFTING) >= 80) {
					player.getInventory().deleteItem(1759, 1);
					player.getInventory().deleteItem(1683, 1);
					player.getInventory().addItem(1712, 1);
					player.getSkills().addXp(Skills.CRAFTING, 4);
					player.getPackets().sendGameMessage("You string the amulet to create an Amulet of Glory (4).");
					return;
				} else {
					player.getDialogueManager().startDialogue("SimpleMessage", "You need a crafting level of 80 to create that.");
					return;
				}
			}
			if ((itemUsed.getId() == 1759 && usedWith.getId() == 6579) || (itemUsed.getId() == 6579 && usedWith.getId() == 1759)) {
				if (player.getSkills().getLevel(Skills.CRAFTING) >= 90) {
					player.getInventory().deleteItem(1759, 1);
					player.getInventory().deleteItem(6579, 1);
					player.getInventory().addItem(6585, 1);
					player.getSkills().addXp(Skills.CRAFTING, 4);
					player.getPackets().sendGameMessage("You string the amulet to create an Amulet of Fury.");
					return;
				} else {
					player.getDialogueManager().startDialogue("SimpleMessage", "You need a crafting level of 90 to create that.");
					return;
				}
			}
			if ((itemUsed.getId() == 4166 || usedWith.getId() == 4164 || usedWith.getId() == 4168 || usedWith.getId() == 4551 || usedWith.getId() == 8192) && player.learnHelm) {
				if (player.getInventory().containsItem(4166, 1) && player.getInventory().containsItem(4164, 1) && player.getInventory().containsItem(4168, 1) && player.getInventory().containsItem(4551, 1) && player.getInventory().containsItem(8921, 1)) {
					player.getInventory().deleteItem(4166, 1);
					player.getInventory().deleteItem(4164, 1);
					player.getInventory().deleteItem(4168, 1);
					player.getInventory().deleteItem(4551, 1);
					player.getInventory().deleteItem(8921, 1);
					player.getInventory().addItem(13263, 1);
				}
			}
			if ((itemUsed.getId() == 4164 || usedWith.getId() == 4166 || usedWith.getId() == 4168 || usedWith.getId() == 4551 || usedWith.getId() == 8192) && player.learnHelm) {
				if (player.getInventory().containsItem(4166, 1) && player.getInventory().containsItem(4164, 1) && player.getInventory().containsItem(4168, 1) && player.getInventory().containsItem(4551, 1) && player.getInventory().containsItem(8921, 1)) {
					player.getInventory().deleteItem(4166, 1);
					player.getInventory().deleteItem(4164, 1);
					player.getInventory().deleteItem(4168, 1);
					player.getInventory().deleteItem(4551, 1);
					player.getInventory().deleteItem(8921, 1);
					player.getInventory().addItem(13263, 1);
				}
			}
			if ((itemUsed.getId() == 4168 || usedWith.getId() == 4166 || usedWith.getId() == 4164 || usedWith.getId() == 4551 || usedWith.getId() == 8192) && player.learnHelm) {
				if (player.getInventory().containsItem(4166, 1) && player.getInventory().containsItem(4164, 1) && player.getInventory().containsItem(4168, 1) && player.getInventory().containsItem(4551, 1) && player.getInventory().containsItem(8921, 1)) {
					player.getInventory().deleteItem(4166, 1);
					player.getInventory().deleteItem(4164, 1);
					player.getInventory().deleteItem(4168, 1);
					player.getInventory().deleteItem(4551, 1);
					player.getInventory().deleteItem(8921, 1);
					player.getInventory().addItem(13263, 1);
				}
			}

			if ((itemUsed.getId() == 4551 || usedWith.getId() == 4166 || usedWith.getId() == 4164 || usedWith.getId() == 4168 || usedWith.getId() == 8192) && player.learnHelm) {
				if (player.getInventory().containsItem(4166, 1) && player.getInventory().containsItem(4164, 1) && player.getInventory().containsItem(4168, 1) && player.getInventory().containsItem(4551, 1) && player.getInventory().containsItem(8921, 1)) {
					player.getInventory().deleteItem(4166, 1);
					player.getInventory().deleteItem(4164, 1);
					player.getInventory().deleteItem(4168, 1);
					player.getInventory().deleteItem(4551, 1);
					player.getInventory().deleteItem(8921, 1);
					player.getInventory().addItem(13263, 1);
				}
			}

			if ((itemUsed.getId() == 8192 || usedWith.getId() == 4166 || usedWith.getId() == 4164 || usedWith.getId() == 4551 || usedWith.getId() == 4168) && player.learnHelm) {
				if (player.getInventory().containsItem(4166, 1) && player.getInventory().containsItem(4164, 1) && player.getInventory().containsItem(4168, 1) && player.getInventory().containsItem(4551, 1) && player.getInventory().containsItem(8921, 1)) {
					player.getInventory().deleteItem(4166, 1);
					player.getInventory().deleteItem(4164, 1);
					player.getInventory().deleteItem(4168, 1);
					player.getInventory().deleteItem(4551, 1);
					player.getInventory().deleteItem(8921, 1);
					player.getInventory().addItem(13263, 1);
				}
			}

			if ((itemUsed.getId() == 13263 || usedWith.getId() == 15490 || usedWith.getId() == 15488)) {
				if (player.getInventory().containsItem(13263, 1) && player.getInventory().containsItem(15490, 1) && player.getInventory().containsItem(15488, 1)) {
					player.getInventory().deleteItem(13263, 1);
					player.getInventory().deleteItem(15490, 1);
					player.getInventory().deleteItem(15488, 1);
					player.getInventory().addItem(15492, 1);
				}
			}

			if ((itemUsed.getId() == 15490 || usedWith.getId() == 13263 || usedWith.getId() == 15488)) {
				if (player.getInventory().containsItem(13263, 1) && player.getInventory().containsItem(15490, 1) && player.getInventory().containsItem(15488, 1)) {
					player.getInventory().deleteItem(13263, 1);
					player.getInventory().deleteItem(15490, 1);
					player.getInventory().deleteItem(15488, 1);
					player.getInventory().addItem(15492, 1);
				}
			}

			if ((itemUsed.getId() == 15488 || usedWith.getId() == 13263 || usedWith.getId() == 15490)) {
				if (player.getInventory().containsItem(13263, 1) && player.getInventory().containsItem(15490, 1) && player.getInventory().containsItem(15488, 1)) {
					player.getInventory().deleteItem(13263, 1);
					player.getInventory().deleteItem(15490, 1);
					player.getInventory().deleteItem(15488, 1);
					player.getInventory().addItem(15492, 1);
				}
			}
			if (itemUsed.getId() == 11710 || usedWith.getId() == 11712 || usedWith.getId() == 11714) {
				if (player.getInventory().containsItem(11710, 1) && player.getInventory().containsItem(11712, 1) && player.getInventory().containsItem(11714, 1)) {
					player.getInventory().deleteItem(11710, 1);
					player.getInventory().deleteItem(11712, 1);
					player.getInventory().deleteItem(11714, 1);
					player.getInventory().addItem(11690, 1);
					player.getPackets().sendGameMessage("You attached the shards and made a Godsword Blade.");
				}
			}
			if (itemUsed.getId() == 11690 || usedWith.getId() == 11702) {
				if (player.getInventory().containsItem(11690, 1) && player.getInventory().containsItem(11702, 1)) {
					player.getInventory().deleteItem(11690, 1);
					player.getInventory().deleteItem(11702, 1);
					player.getInventory().addItem(11694, 1);
					player.getPackets().sendGameMessage("You attach the hilt to the blade and made a Armadyl Godsword.");
				}
			}
			if (itemUsed.getId() == 11690 || usedWith.getId() == 11704) {
				if (player.getInventory().containsItem(11690, 1) && player.getInventory().containsItem(11704, 1)) {
					player.getInventory().deleteItem(11690, 1);
					player.getInventory().deleteItem(11704, 1);
					player.getInventory().addItem(11696, 1);
					player.getPackets().sendGameMessage("You attach the hilt to the blade and made a Bandos Godsword.");
				}
			}
			if (itemUsed.getId() == 11690 || usedWith.getId() == 11706) {
				if (player.getInventory().containsItem(11690, 1) && player.getInventory().containsItem(11706, 1)) {
					player.getInventory().deleteItem(11690, 1);
					player.getInventory().deleteItem(11706, 1);
					player.getInventory().addItem(11698, 1);
					player.getPackets().sendGameMessage("You attach the hilt to the blade and made a Saradomin Godsword.");
				}
			}
			if (itemUsed.getId() == 11690 || usedWith.getId() == 11708) {
				if (player.getInventory().containsItem(11690, 1) && player.getInventory().containsItem(11708, 1)) {
					player.getInventory().deleteItem(11690, 1);
					player.getInventory().deleteItem(11708, 1);
					player.getInventory().addItem(11700, 1);
					player.getPackets().sendGameMessage("You attach the hilt to the blade and made a Zamorak Godsword.");
				}
			}
			if (itemUsed.getId() == 22451 || usedWith.getId() == 22452) {
                if (player.getInventory().containsItem(22452, 1)
                                && player.getInventory().containsItem(22451, 3000)) {
                        player.getInventory().deleteItem(22452, 1);
                        player.getInventory().deleteItem(22451, 3000);
                        player.getInventory().addItem(22482, 1);
						player.getPackets().sendGameMessage("You make a ganodermic visor.");
                }
            }
			if (itemUsed.getId() == 22451 || usedWith.getId() == 22456) {
                if (player.getInventory().containsItem(22456, 1)
                                && player.getInventory().containsItem(22451, 5000)) {
                        player.getInventory().deleteItem(22456, 1);
                        player.getInventory().deleteItem(22451, 5000);
                        player.getInventory().addItem(22490, 1);
						player.getPackets().sendGameMessage("You make a ganodermic poncho.");
                }
            }
			if (itemUsed.getId() == 22451 || usedWith.getId() == 22454) {
                if (player.getInventory().containsItem(22454, 1)
                                && player.getInventory().containsItem(22451, 4000)) {
                        player.getInventory().deleteItem(22454, 1);
                        player.getInventory().deleteItem(22451, 4000);
                        player.getInventory().addItem(22486, 1);
						player.getPackets().sendGameMessage("You make some ganodermic leggings.");
                }
            }
			int herblore = Herblore.isHerbloreSkill(itemUsed, usedWith);
			if (herblore > -1) {
				player.getDialogueManager().startDialogue("HerbloreD", herblore, itemUsed, usedWith);
				return;
			}
			if (itemUsed.getId() == LeatherCrafting.NEEDLE.getId() || usedWith.getId() == LeatherCrafting.NEEDLE.getId()) {
				if (LeatherCrafting.handleItemOnItem(player, itemUsed, usedWith)) {
					return;
				}
			}
			Sets set = ArmourSets.getArmourSet(itemUsedId, itemUsedWithId);
			if (set != null) {
				ArmourSets.exchangeSets(player, set);
				return;
			}
			if (Firemaking.isFiremaking(player, itemUsed, usedWith)) {
				return;
			} else if (itemUsed.getId() == 22448 && usedWith.getId() == 22498) {
				if (player.getEquipment().hasShield() || player.getEquipment().hasTwoHandedWeapon() || player.getEquipment().getWeaponId() != -1) {
					player.getPackets().sendGameMessage("This is a complicated process. You'll need both hands free.");
					return;
				} else if (player.getInventory().containsItem(22448, 3000) && player.getInventory().containsItem(22498, 1) && player.getInventory().containsItem(554, 15000) && player.getSkills().getLevelForXp(Skills.FARMING) >= 80) {
					player.setNextAnimation(new Animation(15434));
					player.setNextGraphics(new Graphics(2032));
					player.getInventory().deleteItem(22448, 3000);
					player.getInventory().deleteItem(22498, 1);
					player.getInventory().deleteItem(554, 15000);
					player.getInventory().addItem(22494, 1);
					player.getSkills().addXp(Skills.FARMING, 300);
					player.getDialogueManager().startDialogue("ItemDialogue", 22494, "You created a Polypore staff.");
				} else {
					if (player.getSkills().getLevel(Skills.FARMING) < 80) {
						player.getPackets().sendGameMessage("You require at least 80 Farming to do this.");
						return;
					} else {
						player.getPackets().sendGameMessage("You require 5 fire runes for each polypore spore. The staff will not accept substitutes.");
						return;
					}
				}
			} else if (contains(1755, Gem.OPAL.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.OPAL);
			} else if (contains(1755, Gem.JADE.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.JADE);
			} else if (contains(1755, Gem.RED_TOPAZ.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.RED_TOPAZ);
			} else if (contains(1755, Gem.SAPPHIRE.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.SAPPHIRE);
			} else if (contains(1755, Gem.EMERALD.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.EMERALD);
			} else if (contains(1755, Gem.RUBY.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.RUBY);
			} else if (contains(1755, Gem.DIAMOND.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.DIAMOND);
			} else if (contains(1755, Gem.DRAGONSTONE.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.DRAGONSTONE);
			} else if (itemUsed.getId() == 21369 && usedWith.getId() == 4151) {
				player.getInventory().deleteItem(21369, 1);
				player.getInventory().deleteItem(4151, 1);
				player.getInventory().addItem(21371, 1);
				player.getPackets().sendGameMessage("Good job, you have succesfully combined a whip and vine into a vine whip.");
			} else if (itemUsed.getId() == 4151 && usedWith.getId() == 21369) {
				player.getInventory().deleteItem(21369, 1);
				player.getInventory().deleteItem(4151, 1);
				player.getInventory().addItem(21371, 1);
				player.getPackets().sendGameMessage("Good job, you have succesfully combined a whip and vine into a vine whip.");
			} else if (itemUsed.getId() == 13734 && usedWith.getId() == 13754) {
				player.getInventory().deleteItem(13734, 1);
				player.getInventory().deleteItem(13754, 1);
				player.getInventory().addItem(13736, 1);
				player.getPackets().sendGameMessage("You have poured the holy elixir on a spirit shield making it unleash Blessed powers.");
				InventoryOptionsHandler.handleItemOnItem(player, stream);
			} else if (itemUsed.getId() == 13754 && usedWith.getId() == 13734) {
				player.getInventory().deleteItem(13734, 1);
				player.getInventory().deleteItem(13754, 1);
				player.getInventory().addItem(13736, 1);
				player.getPackets().sendGameMessage("You have poured the holy elixir on a spirit shield making it unleash Blessed powers.");
			} else if (itemUsed.getId() == 13736 && usedWith.getId() == 13748) {
				player.getInventory().deleteItem(13736, 1);
				player.getInventory().deleteItem(13748, 1);
				player.getInventory().addItem(13740, 1);
				player.getPackets().sendGameMessage("You force the sigil upon the blessed spirit shield making it unleash Divine Powers.");
			} else if (itemUsed.getId() == 13736 && usedWith.getId() == 13750) {
				player.getInventory().deleteItem(13736, 1);
				player.getInventory().deleteItem(13750, 1);
				player.getInventory().addItem(13742, 1);
				player.getPackets().sendGameMessage("You force the sigil upon the blessed spirit shield making it unleash Elysian Powers.");
			} else if (itemUsed.getId() == 13736 && usedWith.getId() == 13746) {
				player.getInventory().deleteItem(13736, 1);
				player.getInventory().deleteItem(13746, 1);
				player.getInventory().addItem(13738, 1);
				player.getPackets().sendGameMessage("You force the sigil upon the blessed spirit shield making it unleash Arcane Powers.");
			} else if (itemUsed.getId() == 13746 && usedWith.getId() == 13736) {
				player.getInventory().deleteItem(13736, 1);
				player.getInventory().deleteItem(13746, 1);
				player.getInventory().addItem(13738, 1);
				player.getPackets().sendGameMessage("You force the sigil upon the blessed spirit shield making it unleash Arcane Powers.");
			} else if (itemUsed.getId() == 13736 && usedWith.getId() == 13752) {
				player.getInventory().deleteItem(13736, 1);
				player.getInventory().deleteItem(13752, 1);
				player.getInventory().addItem(13744, 1);
				player.getPackets().sendGameMessage("You force the sigil upon the blessed spirit shield making it unleash Spectral Powers.");
			} else if (itemUsed.getId() == 13752 && usedWith.getId() == 13736) {
				player.getInventory().deleteItem(13736, 1);
				player.getInventory().deleteItem(13752, 1);
				player.getInventory().addItem(13744, 1);
				player.getPackets().sendGameMessage("You force the sigil upon the blessed spirit shield making it unleash Spectral Powers.");
			} else if (itemUsed.getId() == 1755 && usedWith.getId() == 11864) {
				player.getInventory().deleteItem(11864, 1);
				player.getInventory().addItem(1135, 1);
				player.getInventory().addItem(1099, 1);
				player.getInventory().addItem(1065, 1);
				player.getPackets().sendGameMessage("You used the chisel on the Dragon Hide Set.");
			} else if (itemUsed.getId() == 1755 && usedWith.getId() == 11868) {
				player.getInventory().deleteItem(11868, 1);
				player.getInventory().addItem(2501, 1);
				player.getInventory().addItem(2495, 1);
				player.getInventory().addItem(2489, 1);
				player.getPackets().sendGameMessage("You used the chisel on the Dragon Hide Set.");
			} else if (itemUsed.getId() == 1755 && usedWith.getId() == 11870) {
				player.getInventory().deleteItem(11870, 1);
				player.getInventory().addItem(2503, 1);
				player.getInventory().addItem(2497, 1);
				player.getInventory().addItem(2491, 1);
				player.getPackets().sendGameMessage("You used the chisel on the Dragon Hide Set.");
			} else if (itemUsed.getId() == 1540 && usedWith.getId() == 11286){
				player.getInventory().deleteItem(1540, 1);
				player.getInventory().deleteItem(11286, 1);
				player.getInventory().addItem(11284, 1);
				player.getSkills().addXp(Skills.SMITHING, 25000);
				player.getPackets().sendGameMessage("You combined the draconic visage and the anti-dragon shield to a dragonfire shield.");
			} else if (itemUsed.getId() == 2366 && usedWith.getId() == 2368) {
				player.getInventory().deleteItem(2366, 1);
				player.getInventory().deleteItem(2368, 1);
				player.getInventory().addItem(1187, 1);
				player.getPackets().sendGameMessage("You combine the right and the left part to a Dragon SQ Shield.");
			} else if (contains(1755, Gem.ONYX.getUncut(), itemUsed, usedWith)) {
				GemCutting.cut(player, Gem.ONYX);
			} else {
				player.getPackets().sendGameMessage("Nothing interesting happens.");
			}
			if (Settings.DEBUG) {
				Logger.log("ItemHandler", "Used:" + itemUsed.getId() + ", With:" + usedWith.getId());
			}
		}
	}

	public static void handleItemOption3(Player player, int slotId, int itemId, Item item) {
		long time = Utils.currentTimeMillis();
		if (player.getLockDelay() >= time || player.getEmotesManager().getNextEmoteEnd() >= time) {
			return;
		}
		if (KitsMade.kitsMade.containsKey(itemId)) {
			KitManager.splitItem(player, itemId);
			return;
		}
		player.stopAll(false);
		switch (itemId) {
		case 20767:
		case 20769:
		case 20771:
			SkillCapeCustomizer.startCustomizing(player, itemId);
			break;
		case 15084:
		case 15085:
		case 15086:
		case 15087:
		case 15088:
		case 15089:
		case 15090:
		case 15091:
		case 15092:
		case 15093:
		case 15094:
		case 15095:
		case 15096:
		case 15097:
		case 15098:
		case 15099:
		case 15100:
			player.getDialogueManager().startDialogue("DiceBag", itemId);
			break;
		case 24437:
		case 24439:
		case 24440:
		case 24441:
			player.getDialogueManager().startDialogue("FlamingSkull", item, slotId);
			break;
		}
		if (Equipment.getItemSlot(itemId) == Equipment.SLOT_AURA) {
			player.getAuraManager().sendTimeRemaining(itemId);
		}
	}

	public static void handleItemOption4(Player player, int slotId, int itemId, Item item) {
		System.out.println("Option 4");
	}

	public static void handleItemOption5(Player player, int slotId, int itemId, Item item) {
		System.out.println("Option 5");
	}

	@SuppressWarnings("unused")
	private static String getFormattedNumber(int amount) {
		return new DecimalFormat("#,###,##0").format(amount).toString();
	}

	public static void handleItemOption6(Player player, int slotId, int itemId, Item item) {
		long time = Utils.currentTimeMillis();
		if (player.getLockDelay() >= time || player.getEmotesManager().getNextEmoteEnd() >= time)
			return;
		player.stopAll(false);
		Pouches pouches = Pouches.forId(itemId);
		if (pouches != null) {
			Summoning.spawnFamiliar(player, pouches);
		}
		switch (itemId) {
		case 1438:
			Runecrafting.locate(player, 3127, 3405);
			break;
		case 1440:
			Runecrafting.locate(player, 3306, 3474);
			break;
		case 1442:
			Runecrafting.locate(player, 3313, 3255);
			break;
		case 1444:
			Runecrafting.locate(player, 3185, 3165);
			break;
		case 1446:
			Runecrafting.locate(player, 3053, 3445);
			break;
		case 1448:
			Runecrafting.locate(player, 2982, 3514);
			break;
		case 1706:
		case 1707:
		case 1708:
		case 1709:
		case 1710:
		case 1711:
		case 1712:
		case 10354:
		case 10355:
		case 10356:
		case 10357:
		case 10358:
		case 10359:
		case 10360:
		case 10361:
		case 10362:
			player.getDialogueManager().startDialogue("Transportation", "Edgeville", new WorldTile(3081, 3496, 0), "Karamja", new WorldTile(2918, 3178, 0), "Draynor VillFW", new WorldTile(3105, 3251, 0), "Al Kharid", new WorldTile(3293, 3163, 0), itemId);
			break;
		case 995:
			int amount = player.getInventory().getItems().getNumberOf(995);
			if (player.money + amount > 0) {
				player.getInventory().deleteItem(995, amount);
				player.getPackets().sendRunScript(5561, 1, amount);
				player.money += amount;
				player.refreshMoneyPouch();
			} else {
				player.getPackets().sendGameMessage("You can't have more then 2,147,483,647 coins in your pouch.");
			}
		case 1704:
		case 10352:
			player.getPackets().sendGameMessage("The amulet has ran out of charges. You need to recharge it if you wish to use it once more.");
			break;
		case 3853:
		case 3854:
		case 3855:
		case 3856:
		case 3857:
		case 3858:
		case 3859:
		case 3860:
		case 3861:
		case 3862:
		case 3863:
		case 3864:
		case 3865:
		case 3866:
		case 3567:
			player.getDialogueManager().startDialogue("Transportation", "Burthrope Games Room", new WorldTile(2880, 3559, 0), "Barbarian Outpost", new WorldTile(2519, 3571, 0), "Gamers' Grotto", new WorldTile(2970, 9679, 0), "Corporeal Beast", new WorldTile(2886, 4377, 0), itemId);
			break;
		}
	}

	public static void handleItemOption7(Player player, int slotId, int itemId, Item item) {
		long time = Utils.currentTimeMillis();
		if (player.getLockDelay() >= time || player.getEmotesManager().getNextEmoteEnd() >= time)
			return;
		if (!player.getControlerManager().canDropItem(item))
			return;
		player.stopAll(false);
		if (item.getDefinitions().isOverSized()) {
			player.getPackets().sendGameMessage("The item appears to be oversized.");
			player.getInventory().deleteItem(item);
			return;
		}
		if (item.getDefinitions().isDestroyItem()) {
			player.getDialogueManager().startDialogue("DestroyItemOption", slotId, item);
			return;
		}
		if (player.getPetManager().spawnPet(itemId, true)) {
			return;
		}
		player.getInventory().deleteItem(slotId, item);
		// if (player.getCharges().degradeCompletly(item))
		// return;
		World.addGroundItem(item, new WorldTile(player), player, false, 180, true);
		player.getPackets().sendSound(2739, 0, 1);
	}

	public static void handleItemOption8(Player player, int slotId, int itemId, Item item) {
		player.getInventory().sendExamine(slotId);
	}
	
	public static void handleItemOnPlayer(final Player player,
			final Player usedOn, final int itemId) {
		player.setCoordsEvent(new CoordsEvent(usedOn, new Runnable() {
			public void run() {
				player.faceEntity(usedOn);
				if (usedOn.getInterfaceManager().containsScreenInter()) {
					player.getPackets().sendGameMessage(usedOn.getDisplayName() + " is busy.");
					return;
				}
				if (!usedOn.hasAcceptAid()) {
					player.getPackets().sendGameMessage(usedOn.getDisplayName()
							+ " is not accepting aid.");
					return;
				}
				switch (itemId) {
				case 962:// Christmas cracker
					if (player.getInventory().getFreeSlots() < 3
							|| usedOn.getInventory().getFreeSlots() < 3) {
						player.getPackets().sendGameMessage((player.getInventory()
								.getFreeSlots() < 3 ? "You do"
								: "The other player does")
								+ " not have enough inventory space to open this cracker.");
						return;
					}
					player.getDialogueManager().startDialogue(
							"ChristmasCrackerD", usedOn, itemId);
					break;
				case 2518:
					player.setNextAnimation(new Animation(1)); //TODO find right one
					player.setNextGraphics(new Graphics(30));
					World.sendProjectile(player, usedOn, 29, 18, 18, 50, 50, 20,0);
				    WorldTasksManager.schedule(new WorldTask() {
						@Override
						public void run() {
							usedOn.setNextGraphics(new Graphics(31));
						}
					}, 1);
					break;
				default:
					player.getPackets().sendGameMessage("Nothing interesting happens.");
					break;
				}
			}
		}, usedOn.getSize()));
	}
	public static void handleItemOnNPC(final Player player, final NPC npc, final Item item) {
		if (item == null) {
			return;
		}
		player.setCoordsEvent(new CoordsEvent(npc, new Runnable() {
			@Override
			public void run() {
				if (!player.getInventory().containsItem(item.getId(), item.getAmount())) {
					return;
				}
				if (npc instanceof Pet) {
					player.faceEntity(npc);
					player.getPetManager().eat(item.getId(), (Pet) npc);
					return;
				}
				switch (npc.getId()) {
				case 7557:
					switch (item.getId()) {
					case 199:
					case 201:
					case 203:
					case 205:
					case 208:
					case 3049:
					case 209:
					case 211:
					case 14836:
					case 213:
					case 3051:
					case 215:
					case 2485:
					case 217:
					case 219:
					case 21626:
					case 207:
						int amount = player.getInventory().getNumerOf(item.getId());
						player.getInventory().deleteItem(item.getId(), amount);
						player.getInventory().addItem(item.getId() + 1, amount);
						break;
					}
				}
			}
		}, npc.getSize()));
	}
}